const suffixes = [
  ['png', 'jpg', 'jpeg', 'bmp', 'gif'],
  ['exe', 'msi',,'fbx','glb','gltf'],
  ['zip', 'rar', '7z'],
  ['mp4', 'avi', 'flv'],
  ['doc', 'docx'],
  ['ppt', 'pptx'],
  ['xls', 'xlsx'],
  ['mp3', 'wav'],
  ['txt']
];

export const judgeFileType = (file) => {
  const fileArr = file.split('.');
  let suffix = fileArr[fileArr.length - 1];
  return suffixes[0].find(item => item === suffix) ? 0 :
    suffixes[1].find(item => item === suffix) ? 1 :
      suffixes[2].find(item => item === suffix) ? 2 :
        suffixes[3].find(item => item === suffix) ? 3 :
          suffixes[4].find(item => item === suffix) ? 4 :
            suffixes[5].find(item => item === suffix) ? 5 :
              suffixes[6].find(item => item === suffix) ? 6 :
                suffixes[7].find(item => item === suffix) ? 7 :
                  suffixes[8].find(item => item === suffix) ? 8 : 9;
}
export const bitConvert = (limit) => {
  let size = "";
  if (limit < 0.1 * 1024) {
    size = limit.toFixed(2) + "B"
  } else if (limit < 0.1 * 1024 * 1024) {
    size = (limit / 1024).toFixed(2) + "KB"
  } else if (limit < 0.1 * 1024 * 1024 * 1024) {
    size = (limit / (1024 * 1024)).toFixed(2) + "MB"
  } else {
    size = (limit / (1024 * 1024 * 1024)).toFixed(2) + "GB"
  }
  let sizeStr = size + "";
  let index = sizeStr.indexOf(".");
  let dou = sizeStr.substr(index + 1, 2)
  if (dou === "00") {
    return sizeStr.substring(0, index) + sizeStr.substr(index + 3, 2)
  }
  return size;
};



